package grun

import (
	"encoding/json"
)

type Node struct {
	NodeInfo
	LogMine *LogMine
	Wait    []*Node // 在运行当前任务之前要并行运行的一堆任务
	Next    *Node   // 下一个任务
}

func NewNode(name string, funcInfo *NodeFunc, param interface{}) *Node {
	return &Node{
		NodeInfo: NodeInfo{
			Name:      name,
			FuncName:  funcInfo.Name,
			Param:     param,
			IsSuccess: false,
			Error:     nil,
		},
	}
}

func (n *Node) Export() ([]byte, error) {
	return json.Marshal(n.NodeInfo)
}

func (n *Node) Import(objJson []byte) error {
	return json.Unmarshal(objJson, &n.NodeInfo)
}
